#include "../libs/iniparser/iniparser.h"
#include <stdio.h>
#include <stdlib.h>

// gcc main.c ./iniparser/dictionary.c ./iniparser/iniparser.c -o
// bin/app_iniparser
static void iniparser_example() {
	dictionary *ini = iniparser_load("etc/config.ini");
	if (ini == NULL) {
		printf("ini文件加载失败\n");
		exit(1);
	}

	const char *name = iniparser_getstring(ini, "app:name", NULL);
	const int port = iniparser_getint(ini, "app:port", -1);
	const char *host = iniparser_getstring(ini, "redis:host", NULL);
	const int redisPort = iniparser_getint(ini, "redis:port", -1);

	printf("Name: %s\n", name);
	printf("Port: %d\n", port);
	printf("Redis Host: %s\n", host);
	printf("Redis Port: %d\n", redisPort);

	iniparser_freedict(ini);
}
